using System;

namespace RomanJendrusz.Amazon.ETL.Messages
{
    public class GetItemsCountResponse: AmazonResponse
    {
        private int rowsPerPage = 5;

        public GetItemsCountResponse(Guid correlationId) : base(correlationId)
        {
        }

        public int ItemsCount { get; set; }

        public int PageCount
        {
             get
             {
                 if (rowsPerPage < 1)
                {
                     return 0;
                 }
                 var count = ItemsCount/RowsPerPage;
                 if((ItemsCount%RowsPerPage)!=0)
                 {
                     count++;
                 }
                 return count;
             }
        }

        public virtual int RowsPerPage
        {
            get { return rowsPerPage; }
            set 
            {
                if (rowsPerPage < 1)
                {
                    rowsPerPage = 1;
                }
                rowsPerPage = value; 
            }
        }


        public bool Equals(GetItemsCountResponse getItemsCountResponse)
        {
            if (getItemsCountResponse == null) return false;
            if (!base.Equals(getItemsCountResponse)) return false;
            return ItemsCount == getItemsCountResponse.ItemsCount;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            return Equals(obj as GetItemsCountResponse);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode() + 29*ItemsCount;
        }
    }
}